home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Emulators / v2600 / Source.lha / Source / amiga_raster.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-25  |  16.5 KB  |  806 lines

  1. /*****************************************************************************
  2.  
  3.    This file is part of x2600, the Atari 2600 Emulator
  4.    ===================================================
  5.    
  6.    Copyright 1996 Alex Hornby. For contributions see the file CREDITS.
  7.  
  8.    This software is distributed under the terms of the GNU General Public
  9.    License. This is free software with ABSOLUTELY NO WARRANTY.
  10.    
  11.    See the file COPYING for Details.
  12.    
  13.    Really tweaked by Matthew Stroup for Amiga v2600, April 24, 1997.
  14.  
  15. ******************************************************************************/
  16.  
  17. /* Raster graphics procedures */
  18.  
  19. #include "types.h"
  20. #include "vmachine.h"
  21. #include "display.h"
  22. #include "collision.h"
  23. #include "options.h"
  24. #include "address.h"
  25.  
  26. /* Color lookup tables. Used to speed up rendering */
  27. /* The current colour lookup table */
  28. int *colour_lookup;  
  29.  
  30. /* Colour table */
  31. #define P0M0_COLOUR 0
  32. #define P1M1_COLOUR 1
  33. #define PFBL_COLOUR 2
  34. #define BK_COLOUR 3
  35. UBYTE colour_table[4];
  36.  
  37. /* normal/alternate, not scores/scores*/
  38. int norm_val, scores_val;
  39. int *colour_ptrs[2][3];
  40.  
  41. /* Normal priority */
  42. static int colour_normal[64];
  43. static int colour_normscoresl[64];
  44. static int colour_normscoresr[64];
  45.  
  46. /* Alternate priority */
  47. static int colour_alternate[64];
  48. static int colour_altscoresl[64];
  49. static int colour_altscoresr[64];
  50.  
  51. /* Playfield screen position */
  52. UINT32 *pf_pos;
  53. UBYTE *line_ptr;
  54. UBYTE bkc;
  55.  
  56. /* Draw playfield register PF0 */
  57. /* pf: playfield structure */
  58. /* dir: 1=normal, 0=mirrored */
  59. __inline void draw_pf0 (struct PlayField *pf, int dir)
  60. {
  61.   int pfm;            /* playfield mask */
  62.   /* 1=forward */
  63.   if (dir)
  64.     {
  65.       for (pfm = 0x10; pfm < 0x100; pfm <<= 1)
  66.     {
  67.       if (pf->pf0 & pfm)
  68.         *(pf_pos++) = PF_MASK32;
  69.       else
  70.         pf_pos++;
  71.     }
  72.     }
  73.   else
  74.     {
  75.       for (pfm = 0x80; pfm > 0x08; pfm >>= 1)
  76.     {
  77.       if (pf->pf0 & pfm)
  78.         *(pf_pos++) = PF_MASK32;
  79.       else
  80.         pf_pos++;
  81.     }
  82.     }
  83. }
  84.  
  85. /* Draw playfield register PF1 */
  86. /* pf: playfield structure */
  87. /* dir: 1=normal, 0=mirrored */
  88. __inline void draw_pf1 (struct PlayField *pf, int dir)
  89. {
  90.   int pfm;            /* playfield mask */
  91.   /* 1=forward */
  92.   if (dir)
  93.     {
  94.       /* do PF1 */
  95.       for (pfm = 0x80; pfm > 0; pfm >>= 1)
  96.     {
  97.       if (pf->pf1 & pfm)
  98.         *(pf_pos++) = PF_MASK32;
  99.       else
  100.         pf_pos ++;
  101.     }
  102.     }
  103.   else
  104.     {
  105.       /* do PF1 */
  106.       for (pfm = 0x01; pfm < 0x100; pfm <<= 1)
  107.     {
  108.       if (pf->pf1 & pfm)
  109.         *(pf_pos++) = PF_MASK32;
  110.       else
  111.         pf_pos ++;
  112.     }
  113.     }
  114. }
  115.  
  116. /* Draw playfield register PF2 */
  117. /* pf: playfield structure */
  118. /* dir: 1=normal, 0=mirrored */
  119. __inline void draw_pf2 (struct PlayField *pf, int dir)
  120. {
  121.   int pfm;            /* playfield mask */
  122.   /* 1=forward */
  123.   if (dir)
  124.     {
  125.       /* do PF2 */
  126.       for (pfm = 0x01; pfm < 0x100; pfm <<= 1)
  127.     {
  128.       if (pf->pf2 & pfm)
  129.         *(pf_pos++) = PF_MASK32;
  130.       else
  131.         pf_pos ++;
  132.     }
  133.     }
  134.   else
  135.     {
  136.       for (pfm = 0x80; pfm > 0; pfm >>= 1)
  137.     {
  138.       if (pf->pf2 & pfm)
  139.         *(pf_pos++) = PF_MASK32;
  140.       else
  141.         pf_pos ++;
  142.     }
  143.     }
  144. }
  145.  
  146. /* Update from the playfield display list */
  147. /* num: playfield to use. Now depreciated as only pf[0] is used */
  148. /* nextx: the start position of the next playfield element */
  149. /* pfc: the number of the next playfield change structure */
  150. /* pf_max: the highest playfield change structure */
  151. __inline void pf_update (int num, int nextx, int *pfc, int pf_max)
  152. {
  153.   for (; (*pfc < pf_max) && (nextx + 3 > pf_change[num][*pfc].x); (*pfc)++)
  154.     {
  155.       use_pfraster_change (&pf[num], &pf_change[num][*pfc]);
  156.     }
  157. }
  158.  
  159. /* Draw the playfield */
  160. void draw_playfield (void)
  161. {
  162.   const int num = 0;        /* Stick to one playfield */
  163.   int pfc = 0;
  164.   int pf_max = pf_change_count[num];
  165.  
  166.   pf_pos = (UINT32 *)colvect;
  167.   /* First half of playfield */
  168.  
  169.   pf_update (num, 0, &pfc, pf_max);
  170.   draw_pf0 (&pf[0], 1);
  171.   pf_update (num, 16, &pfc, pf_max);
  172.   draw_pf1 (&pf[0], 1);
  173.   pf_update (num, 48, &pfc, pf_max);
  174.   draw_pf2 (&pf[0], 1);
  175.  
  176.   pf_update (num, 80, &pfc, pf_max);
  177.   /* Second half of playfield */
  178.   if (pf[0].ref)
  179.     {
  180.       draw_pf2 (&pf[0], 0);
  181.       pf_update (num, 112, &pfc, pf_max);
  182.       draw_pf1 (&pf[0], 0);
  183.       pf_update (num, 144, &pfc, pf_max);
  184.       draw_pf0 (&pf[0], 0);
  185.     }
  186.   else
  187.     {
  188.       draw_pf0 (&pf[0], 1);
  189.       pf_update (num, 96, &pfc, pf_max);
  190.       draw_pf1 (&pf[0], 1);
  191.       pf_update (num, 128, &pfc, pf_max);
  192.       draw_pf2 (&pf[0], 1);
  193.     }
  194.   /* Use last changes */
  195.   for (; pfc < pf_max; pfc++)
  196.     use_pfraster_change (&pf[num], &pf_change[num][pfc]);
  197.  
  198.   pf_change_count[num] = 0;
  199. }
  200.  
  201. /* Draws a normal (8 clocks) sized player */
  202. /* p: the player to draw */
  203. /* x: the position to draw it */
  204. __inline void pl_normal (struct Player *p, int x)
  205. {
  206.   /* Set pointer to start of player graphic */
  207.   UBYTE *ptr = colvect + x;
  208.   UBYTE mask;
  209.   UBYTE gr;
  210.  
  211.   if (p->vdel_flag)
  212.     gr = p->vdel;
  213.   else
  214.     gr = p->grp;
  215.  
  216.   if (p->reflect)
  217.     {
  218.       /* Reflected: start with D0 of GRP on left */
  219.       for (mask = 0x01; mask > 0; mask <<= 1)
  220.     {
  221.       if (gr & mask)
  222.         {
  223.           *(ptr++) |= p->mask;
  224.         }
  225.       else
  226.         ptr++;
  227.     }
  228.     }
  229.   else
  230.     {
  231.       /* Unreflected: start with D7 of GRP on left */
  232.       for (mask = 0x80; mask > 0; mask >>= 1)
  233.     {
  234.       if (gr & mask)
  235.         {
  236.           *(ptr++) |= p->mask;
  237.         }
  238.       else
  239.         ptr++;
  240.     }
  241.     }
  242. }
  243.  
  244. /* Draws a double width ( 16 clocks ) player */
  245. /* p: the player to draw */
  246. /* x: the position to draw it */
  247. __inline void pl_double (struct Player *p, int x)
  248. {
  249.   /* Set pointer to start of player graphic */
  250.   UBYTE *ptr = colvect + (x);
  251.   UBYTE mask;
  252.   UBYTE gr;
  253.  
  254.   if (p->vdel_flag)
  255.     gr = p->vdel;
  256.   else
  257.     gr = p->grp;
  258.  
  259.   if (p->reflect)
  260.     {
  261.       for (mask = 0x01; mask > 0; mask <<= 1)
  262.     {
  263.       if (gr & mask)
  264.         {
  265.           *(ptr++) |= p->mask;
  266.           *(ptr++) |= p->mask;
  267.         }
  268.       else
  269.         ptr += 2;
  270.     }
  271.     }
  272.   else
  273.     {
  274.       for (mask = 0x80; mask > 0; mask >>= 1)
  275.     {
  276.       if (gr & mask)
  277.         {
  278.           *(ptr++) |= p->mask;
  279.           *(ptr++) |= p->mask;
  280.         }
  281.       else
  282.         ptr += 2;
  283.     }
  284.     }
  285. }
  286.  
  287. /* Draws a quad sized ( 32 clocks) player */
  288. /* p: the player to draw */
  289. /* x: the position to draw it */
  290. __inline void pl_quad (struct Player *p, int x)
  291. {
  292.   /* Set pointer to start of player graphic */
  293.   UBYTE *ptr = colvect + x;
  294.   UBYTE mask;
  295.   UBYTE gr;
  296.  
  297.   if (p->vdel_flag)
  298.     gr = p->vdel;
  299.   else
  300.     gr = p->grp;
  301.  
  302.   if (p->reflect)
  303.     {
  304.       for (mask = 0x01; mask > 0; mask <<= 1)
  305.     {
  306.       if (gr & mask)
  307.         {
  308.           *(ptr++) |= p->mask;
  309.           *(ptr++) |= p->mask;
  310.           *(ptr++) |= p->mask;
  311.           *(ptr++) |= p->mask;
  312.         }
  313.       else
  314.         ptr += 4;
  315.     }
  316.     }
  317.   else
  318.     {
  319.       for (mask = 0x80; mask > 0; mask >>= 1)
  320.     {
  321.       if (gr & mask)
  322.         {
  323.           *(ptr++) |= p->mask;
  324.           *(ptr++) |= p->mask;
  325.           *(ptr++) |= p->mask;
  326.           *(ptr++) |= p->mask;
  327.         }
  328.       else
  329.         ptr += 4;
  330.     }
  331.     }
  332. }
  333.  
  334. /* Consume the player display list */
  335. __inline void pl_update (int num, int nextx, int *plc, int pl_max)
  336. {
  337.   for (; (*plc < pl_max) && (nextx > pl_change[num][*plc].x); (*plc)++)
  338.     {
  339.       use_plraster_change (&pl[num], &pl_change[num][*plc]);
  340.     }
  341. }
  342.  
  343. /* Draw a player graphic */
  344. /* line: the vertical position of the raster */
  345. /* num: the number of player to draw, current 0 or 1 for P0 and P1 */
  346. static __inline void pl_draw (int num)
  347. {
  348.   int plc = 0;
  349.   int pl_max = pl_change_count[num];
  350.   int nextx;
  351.  
  352.   pl_update (num, pl[num].x, &plc, pl_max);
  353.   if (pl[num].x >= 0 && pl[num].x < tv_width)
  354.     {
  355.  
  356.       /*if(pl_max > plc)
  357.          use_plraster_change( &pl[num], &pl_change[num][plc++]); */
  358.       switch (pl[num].nusize)
  359.     {
  360.     case 0:
  361.       /* One copy */
  362.       pl_normal (&pl[num], pl[num].x);
  363.       break;
  364.     case 1:
  365.       /* Two copies close */
  366.       pl_normal (&pl[num], pl[num].x);
  367.       nextx = pl[num].x + 8 + 8;
  368.       pl_update (num, nextx, &plc, pl_max);
  369.       pl_normal (&pl[num], nextx);
  370.       break;
  371.     case 2:
  372.       /* Two copies medium */
  373.       pl_normal (&pl[num], pl[num].x);
  374.       nextx = pl[num].x + 8 + 24;
  375.       pl_update (num, nextx, &plc, pl_max);
  376.       pl_normal (&pl[num], nextx);
  377.       break;
  378.     case 3:
  379.       /* Three copies close */
  380.       /* Pacman score line */
  381.       pl_normal (&pl[num], pl[num].x);
  382.  
  383.       nextx = pl[num].x + 16;
  384.       pl_update (num, nextx, &plc, pl_max);
  385.       pl_normal (&pl[num], nextx);
  386.  
  387.       nextx = pl[num].x + 32;
  388.       pl_update (num, nextx, &plc, pl_max);
  389.  
  390.       pl_normal (&pl[num], nextx);
  391.       break;
  392.     case 4:
  393.       /* Two copies wide */
  394.       pl_normal (&pl[num], pl[num].x);
  395.       nextx = pl[num].x + 8 + 56;
  396.       pl_update (num, nextx, &plc, pl_max);
  397.       pl_normal (&pl[num], nextx);
  398.       break;
  399.     case 5:
  400.       /* Double sized player */
  401.       pl_double (&pl[num], pl[num].x);
  402.       break;
  403.     case 6:
  404.       /* Three copies medium */
  405.       pl_normal (&pl[num], pl[num].x);
  406.       nextx = pl[num].x + 8 + 24;
  407.       pl_update (num, nextx, &plc, pl_max);
  408.       pl_normal (&pl[num], nextx);
  409.       nextx = pl[num].x + 8 + 56;
  410.       pl_update (num, nextx, &plc, pl_max);
  411.       pl_normal (&pl[num], nextx);
  412.       break;
  413.     case 7:
  414.       /* Quad sized player */
  415.       pl_quad (&pl[num], pl[num].x);
  416.       break;
  417.     }
  418.     }
  419.   /* Use last changes */
  420.   for (; plc < pl_max; plc++)
  421.     use_plraster_change (&pl[num], &pl_change[num][plc]);
  422.   pl_change_count[num] = 0;
  423. }
  424.  
  425.  
  426. /* Draw the ball graphic */
  427. /* line: the vertical position of the raster */
  428. static __inline void draw_ball (void)
  429. {
  430.   int i;
  431.   UBYTE *blptr;
  432.   UBYTE e;
  433.  
  434.   if (ml[2].vdel_flag)
  435.     e = ml[2].vdel;
  436.   else
  437.     e = ml[2].enabled;
  438.  
  439.   if (e && ml[2].x >= 0)
  440.     {
  441.       blptr = colvect + (ml[2].x);
  442.       switch (tiaWrite[CTRLPF] >> 4)
  443.     {
  444.     case 3:
  445.       /* Eight clocks */
  446.       for (i = 0; i < 8; i++)
  447.         *(blptr++) |= BL_MASK;
  448.       break;
  449.     case 2:
  450.       /* Four clocks */
  451.       for (i = 0; i < 4; i++)
  452.         *(blptr++) |= BL_MASK;
  453.       break;
  454.     case 1:
  455.       /* Two clocks */
  456.       for (i = 0; i < 2; i++)
  457.         *(blptr++) |= BL_MASK;
  458.       break;
  459.     case 0:
  460.       /* One clock */
  461.       *(blptr++) |= BL_MASK;
  462.       break;
  463.     }
  464.     }
  465. }
  466.  
  467.  
  468. /* Draw a missile graphic */
  469. static __inline void do_missile (int num, UBYTE * misptr)
  470. {
  471.   int i;
  472.  
  473.   misptr = colvect + (ml[num].x);
  474.   switch (ml[num].width)
  475.     {
  476.     case 0:
  477.       /* one clock */
  478.       *(misptr++) |= ml[num].mask;
  479.       break;
  480.     case 1:
  481.       /* two clocks */
  482.       for (i = 0; i < 2; i++)
  483.     *(misptr++) |= ml[num].mask;
  484.       break;
  485.     case 2:
  486.       /* four clocks */
  487.       for (i = 0; i < 4; i++)
  488.     *(misptr++) |= ml[num].mask;
  489.       break;
  490.     case 3:
  491.       /* Eight clocks */
  492.       for (i = 0; i < 8; i++)
  493.     *(misptr++) |= ml[num].mask;
  494.       break;
  495.     }                /* switch */
  496. }
  497.  
  498. /* Draw a missile taking into account the player's position. */
  499. /* line: the vertical position of the raster */
  500. /* num: 0 for M0, 1 for M1 */
  501. static __inline void draw_missile (int num)
  502. {
  503.   UBYTE *misptr;
  504.  
  505.   if (ml[num].enabled && ml[num].x >= 0)
  506.     {
  507.       switch (pl[num].nusize)
  508.     {
  509.     case 0:
  510.       misptr = colvect + (ml[num].x);
  511.       do_missile (num, misptr);
  512.       break;
  513.     case 1:
  514.       misptr = colvect + (ml[num].x);
  515.       do_missile (num, misptr);
  516.       misptr = misptr + 16;
  517.       do_missile (num, misptr);
  518.       break;
  519.     case 2:
  520.       misptr = colvect + (ml[num].x);
  521.       do_missile (num, misptr);
  522.       misptr = misptr + 32;
  523.       do_missile (num, misptr);
  524.       break;
  525.     case 3:
  526.       misptr = colvect + (ml[num].x);
  527.       do_missile (num, misptr);
  528.       misptr = misptr + 16;
  529.       do_missile (num, misptr);
  530.       misptr = misptr + 16;
  531.       do_missile (num, misptr);
  532.       break;
  533.     case 4:
  534.       misptr = colvect + (ml[num].x);
  535.       do_missile (num, misptr);
  536.       misptr = misptr + 64;
  537.       do_missile (num, misptr);
  538.       break;
  539.     case 5:
  540.       misptr = colvect + (ml[num].x);
  541.       do_missile (num, misptr);
  542.       break;
  543.     case 6:
  544.       misptr = colvect + (ml[num].x);
  545.       do_missile (num, misptr);
  546.       misptr = misptr + 32;
  547.       do_missile (num, misptr);
  548.       misptr = misptr + 32;
  549.       do_missile (num, misptr);
  550.       break;
  551.     case 7:
  552.       misptr = colvect + (ml[num].x);
  553.       do_missile (num, misptr);
  554.       break;
  555.  
  556.     }
  557.  
  558.     }                /* If */
  559. }
  560.  
  561.  
  562. /* Construct one tv raster line colvect */
  563. /* line: the vertical position of the raster */
  564. void tv_rasterise (int line)
  565. {
  566.   line_ptr = vscreen + line * vwidth;
  567.  
  568.   /* Draw the playfield first */
  569.   draw_playfield (); 
  570.   
  571.   /* Do the ball */
  572.   draw_ball ();
  573.   
  574.   /* Do the player 1 graphics */
  575.   draw_missile (1);
  576.   pl_draw (1);
  577.   
  578.   /* Do the player 0 graphics */
  579.   draw_missile (0);
  580.   pl_draw (0);
  581. }
  582.  
  583. /* Reset the collision vector */
  584. void reset_vector (void)
  585. {
  586.   int i;
  587.   UINT32 *cpos=(UINT32 *)colvect;
  588.   for (i = 0; i < 40; i++)
  589.     cpos[i] = 0;
  590. }
  591.  
  592.  
  593. /* draw the collision vector */
  594. /* Quick version with no magnification */
  595. void draw_vector_q (void)
  596. {
  597.   int i;
  598.   int uct = 0;
  599.   int colind, colval;
  600.   UBYTE pad;
  601.   UBYTE *tv_ptr = line_ptr;
  602.   
  603.   /* Check for scores */
  604.   if(scores_val ==2) 
  605.     {
  606.       scores_val=1;
  607.       colour_lookup=colour_ptrs[norm_val][scores_val];
  608.     }
  609.  
  610.   /* Use starting changes */
  611.   while (uct < unified_count && unified[uct].x < 0)
  612.     use_unified_change (&unified[uct++]);
  613.  
  614.   for (i = 0; i < 80; i++)
  615.     {
  616.       if (uct < unified_count && unified[uct].x == i)
  617.     use_unified_change (&unified[uct++]);
  618.       
  619.       if((colval=colvect[i])){
  620.     
  621.     /* Collision detection */
  622.     col_state|=col_table[colval];
  623.     
  624.     colind=colour_lookup[colval];
  625.     pad=colors[colour_table[colind]];
  626.       } else
  627.     pad=colors[colour_table[BK_COLOUR]];      
  628.  
  629.     *(tv_ptr++)=pad;
  630.     *(tv_ptr++)=pad;
  631.     }
  632.  
  633.   /* Check for scores */
  634.   if(scores_val ==1)
  635.     {
  636.       scores_val=2;
  637.       colour_lookup=colour_ptrs[norm_val][scores_val];
  638.     }
  639.   for (i = 80; i < 160; i++)
  640.     {
  641.       if (uct < unified_count && unified[uct].x == i)
  642.     use_unified_change (&unified[uct++]);
  643.       
  644.       if((colval=colvect[i])){
  645.     
  646.     /* Collision detection */
  647.     col_state|=col_table[colval];
  648.     
  649.     colind=colour_lookup[colval];
  650.     pad=colors[colour_table[colind]];
  651.       } else
  652.     pad=colors[colour_table[BK_COLOUR]];      
  653.  
  654.     *(tv_ptr++)=pad;
  655.     *(tv_ptr++)=pad;
  656.     }
  657.  
  658.   while (uct < unified_count)
  659.     use_unified_change (&unified[uct++]);
  660.   unified_count = 0;
  661. }
  662.  
  663. /* Used for when running in frame skipping mode */
  664. static __inline void update_registers (void)
  665. {
  666.   int i, num;
  667.  
  668.   /* Playfield */
  669.   for (i = 0; i < pf_change_count[0]; i++)
  670.     use_pfraster_change (&pf[0], &pf_change[0][i]);
  671.   pf_change_count[0] = 0;
  672.  
  673.   /* Player graphics */
  674.   for (num = 0; num < 2; num++)
  675.     {
  676.       for (i = 0; i < pl_change_count[num]; i++)
  677.     use_plraster_change (&pl[num], &pl_change[num][i]);
  678.       pl_change_count[num] = 0;
  679.     }
  680.  
  681.   /* Unified */
  682.   for (i = 0; i < unified_count; i++)
  683.     use_unified_change (&unified[i]);
  684.   unified_count = 0;
  685. }
  686.  
  687. /* Main raster function, will have switches for different magsteps */
  688. /* line: the vertical position of the raster */
  689. void tv_raster (int line)
  690. {
  691.   if ((tv_counter % base_opts.rr != 0)  || (line > theight) )
  692.     {
  693.       update_registers ();
  694.     }
  695.   else
  696.     {
  697.       reset_vector();
  698.       tv_rasterise (line);
  699.       draw_vector_q();
  700.     }
  701. }
  702.  
  703.  
  704. void init_raster (void)
  705. {
  706.   int i,val;
  707.  
  708.   init_collisions();
  709.  
  710.   /* Normal Priority */
  711.   for (i=0; i<64; i++)
  712.     {
  713.       if (i & (PL0_MASK | ML0_MASK))
  714.     val = P0M0_COLOUR;
  715.       else if (i & (PL1_MASK | ML1_MASK))
  716.     val = P1M1_COLOUR;
  717.       else if (i & (BL_MASK | PF_MASK))
  718.     val = PFBL_COLOUR;
  719.       else
  720.     val = BK_COLOUR;     
  721.       colour_normal[i]=val;
  722.     }
  723.  
  724.   /* Alternate Priority */
  725.   for (i=0; i<64; i++)
  726.     {  
  727.       if (i & (BL_MASK | PF_MASK))
  728.     val = PFBL_COLOUR;
  729.       else if (i & (PL0_MASK | ML0_MASK))
  730.     val = P0M0_COLOUR;
  731.       else if (i & (PL1_MASK | ML1_MASK))
  732.     val = P1M1_COLOUR;
  733.       else
  734.     val = BK_COLOUR;
  735.       colour_alternate[i]=val;
  736.     }
  737.  
  738.   /* Normal Scores Left */
  739.   for (i=0; i<64; i++)
  740.     {
  741.       if (i & (PL0_MASK | ML0_MASK))
  742.     val = P0M0_COLOUR;
  743.       else if (i & (PL1_MASK | ML1_MASK))
  744.     val = P1M1_COLOUR;
  745.       else if (i & (BL_MASK | PF_MASK))
  746.     /* Use P1 colour */
  747.     val = P0M0_COLOUR;
  748.       else
  749.     val = BK_COLOUR;     
  750.       colour_normscoresl[i]=val;
  751.     }
  752.   
  753.   /* Normal Scores Right */
  754.   for (i=0; i<64; i++)
  755.     {
  756.       if (i & (PL0_MASK | ML0_MASK))
  757.     val = P0M0_COLOUR;
  758.       else if (i & (PL1_MASK | ML1_MASK))
  759.     val = P1M1_COLOUR;
  760.       else if (i & (BL_MASK | PF_MASK))
  761.     /* Use P1 colour */
  762.     val = P1M1_COLOUR;
  763.       else
  764.     val = BK_COLOUR;     
  765.       colour_normscoresr[i]=val;
  766.     }
  767.  
  768.   /* Alternate Scores Left*/
  769.   for (i=0; i<64; i++)
  770.     {  
  771.       if (i & (BL_MASK | PF_MASK))
  772.     val = P0M0_COLOUR;
  773.       else if (i & (PL0_MASK | ML0_MASK))
  774.     val = P0M0_COLOUR;
  775.       else if (i & (PL1_MASK | ML1_MASK))
  776.     val = P1M1_COLOUR;
  777.       else
  778.     val = BK_COLOUR;
  779.       colour_altscoresl[i]=val;
  780.     }
  781.  
  782.   /* Alternate Scores Right*/
  783.   for (i=0; i<64; i++)
  784.     {  
  785.       if (i & (BL_MASK | PF_MASK))
  786.     val = P1M1_COLOUR;
  787.       else if (i & (PL0_MASK | ML0_MASK))
  788.     val = P0M0_COLOUR;
  789.       else if (i & (PL1_MASK | ML1_MASK))
  790.     val = P1M1_COLOUR;
  791.       else
  792.     val = BK_COLOUR;
  793.       colour_altscoresr[i]=val;
  794.     }
  795.   
  796.   colour_ptrs[0][0]=colour_normal;
  797.   colour_ptrs[1][0]=colour_alternate;
  798.   colour_ptrs[0][1]=colour_normscoresl;
  799.   colour_ptrs[1][1]=colour_altscoresl;
  800.   colour_ptrs[0][2]=colour_normscoresr;
  801.   colour_ptrs[1][2]=colour_altscoresr;
  802.   norm_val=0; scores_val=0;
  803.  
  804.   colour_lookup=colour_normal;
  805. }
  806.